DECLARE
VN_COUNT    NUMBER;
v_SQL        VARCHAR2(4000);

BEGIN
<#if tableList??&&(tableList?size>0)>
    <#list tableList as t>
        <#if t.tableIndexes?? && (t.tableIndexes?size > 0) >
            <#list t.tableIndexes as indexes>
                BEGIN
                SELECT COUNT(*) INTO V_COUNT FROM user_indexes WHERE index_name = '${indexes.indexesName}' and table_name = '${t.name}';
                IF VN_COUNT <= 0  THEN
                <#if indexes.indexesType=="INDEX">
                    v_SQL := 'create index ${indexes.indexesName} on ${t.name}(${indexes.indexesColumn})'||
                    <#if indexes.tablespace??&&indexes.tablespace!="">
                        ' tablespace ${indexes.tablespace} '
                    </#if>;
                </#if>
                <#if indexes.indexesType == "UNIQUE_INDEX">
                    v_SQL := 'create unique index ${indexes.indexesName} on ${t.name}(${indexes.indexesColumn})'||
                    <#if indexes.tablespace??&&indexes.tablespace!="">
                        ' tablespace ${indexes.tablespace} '
                    </#if>;
                </#if>
                EXECUTE IMMEDIATE V_SQL;
                DBMS_OUTPUT.PUT_LINE('${indexes.indexesName} 索引新建成功');
                ELSE
                DBMS_OUTPUT.PUT_LINE('${indexes.indexesName} 索引已存在');
                END IF;
                exception when  others then
                dbms_output.put_line('错误号：'||sqlcode);
                dbms_output.put_line('错误信息：'||sqlerrm);
                END;
            </#list>
        </#if>

    </#list>
</#if>


END;